<template>
  <el-table ref="singleTable" :data="initData" highlight-current-row @current-change="handleCurrentChange" style="width: 100%">
    <el-table-column :property="name" :label="label"></el-table-column>
  </el-table>
</template>
<script>
export default {
  data() {
    return {
      currentRow: {}
    };
  },
  props: {
    initData: Array,
    name: String,
    label: String
  },
  watch: {
    currentRow(val) {
      this.$emit("input", val[this.name]);
    }
  },
  methods: {
    handleCurrentChange(val) {
      this.currentRow = val;
    },
    setCurrent(row) {
      this.$refs.singleTable.setCurrentRow(row);
    }
  }
  // mounted() {
  //   this.setCurrent(this.initData[0]);
  // }
};
</script>
